package com.content.scaffold.common.utils;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import com.content.scaffold.common.properties.EncryptProperties;

/**
 * @author xiaojl
 */
public class AesEncryptUtil {
    private static final AES AES;

    static {
        EncryptProperties properties = SpringContextHolder.getBean(EncryptProperties.class);
        AES = SecureUtil.aes(SecureUtil.decode(properties.getKey()));
    }

    public static String encrypt(String plaintext) {
        return AES.encryptHex(plaintext);
    }

    public static String decrypt(String plaintext) {
        return AES.decryptStr(plaintext);
    }
}
